<%@page import="cn.sendto.dbhelper.DBHelper"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
   if(request.getSession().getAttribute("user")==null){
	   request.getRequestDispatcher("login.jsp").forward(request, response);
   }

%>
    <%
    /*final String URL1="http://localhost:8080/student/student_info.jsp";
    final String URL2="http://localhost:8080/student/class_info.jsp";
    final String URL3="http://localhost:8080/student/course_info.jsp";*/
    
    final String URL1="http://localhost:8080/student/student_info.jsp";
    final String URL2="http://localhost:8080/student/class_info.jsp";
    final String URL3="http://localhost:8080/student/course_info.jsp";
    final String URL4="http://localhost:8080/student/score_info.jsp";
    //获取跳转前的网址
    String url=request.getHeader("referer");
    DBHelper helper=new DBHelper();
    String id=request.getParameter("id");
    String DELETE=new String();
    
    if(url.equals(URL1)){
    	DELETE="delete from studentinfo where studentid=?";
    	int strudentReturnValue=helper.executeSQL(DELETE, id);
        if(strudentReturnValue<1){
       	 String str="<script>window.location.href=\"student_info.jsp\";alert(\"删除失败，请重试！\");</script>";
       	 out.print(str);
        } else{
       	 String str="<script>window.location.href=\"student_info.jsp\";alert(\"删除成功\");</script>";
       	 out.print(str);
        }
    } else if(url.equals(URL2)){
    	DELETE="delete from classinfo where classid=?";
    	int classReturnValue=helper.executeSQL(DELETE, id);
        if(classReturnValue<1){
       	 String str="<script>window.location.href=\"class_info.jsp\";alert(\"删除失败，请重试！\");</script>";
       	 out.print(str);
        } else{
       	 String str="<script>window.location.href=\"class_info.jsp\";alert(\"删除成功\");</script>";
       	 out.print(str);
        }
    } else if(url.equals(URL3)){
    	DELETE="delete from courseinfo where courseid=?";
    	int courseReturnValue=helper.executeSQL(DELETE, id);
        if(courseReturnValue<1){
       	 String str="<script>window.location.href=\"course_info.jsp\";alert(\"删除失败，请重试！\");</script>";
       	 out.print(str);
        } else{
       	 String str="<script>window.location.href=\"course_info.jsp\";alert(\"删除成功\");</script>";
       	 out.print(str);
        }
    } else if(url.equals(URL4)){
    	DELETE="delete from scoreinfo where scoreid=?";
    	int courseReturnValue=helper.executeSQL(DELETE, id);
        if(courseReturnValue<1){
       	 String str="<script>window.location.href=\"score_info.jsp\";alert(\"删除失败，请重试！\");</script>";
       	 out.print(str);
        } else{
       	 String str="<script>window.location.href=\"score_info.jsp\";alert(\"删除成功\");</script>";
       	 out.print(str);
        }
    }
    
    
     /*DBHelper helper=new DBHelper();
     String id=request.getParameter("id");
     final String DELETE="delete from studentinfo where studentid=?";
     int returnValue=helper.executeSQL(DELETE, id);
     if(returnValue<1){
    	 String str="<script>window.location.href=\"student_info.jsp\";alert(\"删除失败，请重试！\");</script>";
    	 out.print(str);
     } else{
    	 String str="<script>window.location.href=\"student_info.jsp\";alert(\"删除成功\");</script>";
    	 out.print(str);
     }*/
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

</body>
</html>